package com.cskaoyan.dbutils.resultsetHandler;

import com.cskaoyan.bean.Account;
import com.cskaoyan.opensource.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * 创建日期: 2022/11/18 17:34
 *
 * @author ciggar
 */
public class BeanHandlerDemo {

    public static void main(String[] args) throws SQLException {

        // 构建QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        // 查询
        Account account = queryRunner.query("select id as aid,name,money from account where id = ?",new BeanHandler<>(Account.class),1001);

        System.out.println(account);

    }
}
